// 用户注册
import axios from '../../plugins/axios/index'
import Vuex from '../../store/index'
import router from '../../router'
export default {
  /**
   * 获取验证码
   */
  getVerificationCode (phone, callback) {
    axios.request({
      url: 'api/home/send-code',
      method: 'post',
      data: {
        phone
      }
    }).then(function (result) {
      callback(result)
    })
  },
  /**
   * 注册
   */
  registerRequest (data) {
    axios.request({
      url: 'api/home/user',
      method: 'post',
      data: data
    }).then(result => {
      Vuex.commit('setUser', result.data)
      Vuex.commit('setIsLogin', true)
      router.push({ name: 'home' })
    })
  }
}
